﻿(function() {
    GMaps.prototype.addStyle = function(options){		
        var styledMapType = new google.maps.StyledMapType(options.styles, options.styledMapName);
        this.map.mapTypes.set(options.mapTypeId, styledMapType);
    };

    GMaps.prototype.setStyle = function(mapTypeId){		
        this.map.setMapTypeId(mapTypeId);
    };

    $(document).ready(function() {

        var mapDiv = $("#maps_g-maps");

        var latitude = mapDiv.data("latitude");
        var longitude = mapDiv.data("longitude");
        var height = mapDiv.data("height");
        var width = mapDiv.data("width");
        // If there was a problem attaining a lat/long from the input element's value,
        //  set it to a sensible default that isn't in the middle of the ocean.
        if (!latitude || longitude) {
            latitude = 45.50867;
            longitude = -73.553992;
        }

        var gray = [{
                "stylers": [{
                        "hue": "#ff1a00"
                    }, {
                        "invert_lightness": true
                    }, {
                        "saturation": -100
                    }, {
                        "lightness": 33
                    }, {
                        "gamma": 0.5
                    }]
            }, {
                "featureType": "water",
                "elementType": "geometry",
                "stylers": [{
                    "color": "#2D333C"
                }]
            }];
        var map = new GMaps({
            div: '#maps_g-maps',
            lat: latitude,
            lng: longitude,
            width: width,
            height: height,
            scrollwheel:false
        });
        map.addStyle({
            styledMapName: "Styled Map",
            styles: gray,
            mapTypeId: "map_style"
        });

        map.setStyle("map_style");

    });
})();